package com.example.estest.config;

import com.example.estest.elasticsearchconfig.LogstashEquivalent;
import lombok.Data;
import org.elasticsearch.client.RestHighLevelClient;

import java.security.SecureRandom;
import java.util.concurrent.atomic.AtomicInteger;

@Data
public class MyThread implements Runnable{


    String line;
    String path;
    String logpath;
    RestHighLevelClient client;
    String finishlog;
    int atomicInteger;

    public MyThread() {
    }

    public MyThread(String line, String path, String logpath,
                    RestHighLevelClient client, String finishlog,
                    int atomicInteger) {
        this.line = line;
        this.path = path;
        this.logpath = logpath;
        this.client = client;
        this.finishlog = finishlog;
        this.atomicInteger = atomicInteger;

    }

    @Override
    public void run() {
        Thread.currentThread().setName("tjc-Thread-"+atomicInteger+"随机码 "+new SecureRandom().nextInt());   //重取名字利用jconsole观察线程变化，处理bug
        LogstashEquivalent logstashEquivalent = new LogstashEquivalent();
        logstashEquivalent.logstash(line,path,logpath,client,finishlog);
    }
}

